package ru.st.selenium.pages;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindAll;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.FindBys;

public class HomePage extends InternalPage {

  public HomePage(PageManager pages) {
	super(pages);
  }
	
  @FindBy(xpath = "//a[contains(@href, \"./?go=add\")]")
  private WebElement addMovieButton;
  
  @FindBy(xpath = "(//div[contains(@class,'movie_box')])[1]")
  private WebElement firstFilm;
	
//  @FindBy(xpath ="//div[contains(@class,'movie_box')]")
//  private List<WebElement> filmsList;

//  //section//a[1]/div
  
  public AddMoviePage clickAddMovieButton() {
	addMovieButton.click();
	return pages.addMoviePage;
  }	

  public MovieViewPage getFirstFilm() {
//	  List<WebElement> filmsList = driver.findElements(By.xpath("//div[contains(@class,'movie_box')]"));
//	  int index = (int)(Math.random() * filmsList.size());
	  firstFilm.click();
	  return pages.movieViewPage;
  }

}
